<?php
/**
 * function.date_sub.php
 *
 * $Id:$
 */
 
function smarty_function_date_sub($params, $template)
{
	$from = isset($params['from']) ? $params['from'] : date('Y-m-d H:i:s');
	$to = isset($params['to']) ? $params['to'] : date('Y-m-d H:i:s');
	$format = isset($params['format']) ? $params['format'] : '%H %i %s';
	
	// auto convert timestamp to date
	intval($from) == $from && $from = date('Y-m-d H:i:s', $from);
	intval($to) == $to && $to = date('Y-m-d H:i:s', $to);
	
	$val = date_diff(new DateTime($from), new DateTime($to));
	return $val->format($format);
}

/* End file of function.date_sub.php */
/* Location: function.date_interval.php */